﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace BFOAuction
{
    public partial class CurrencyConverter : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btDongY_Click(object sender, EventArgs e)
        {
            double Dollar = 20900;
            double Yen = 230;
            double Euro = 28000;
            double Aus = 21700;

            if (drdLoaiTien.SelectedIndex == drdChuyenThanh.SelectedIndex)
            {
                txtChuyenThanh.Text = txtSoTien.Text;
            }
            if (drdLoaiTien.SelectedIndex==0)
            {
                if (drdChuyenThanh.SelectedIndex == 1)
                {
                    txtChuyenThanh.Text = (Convert.ToDouble(txtSoTien.Text) / Dollar).ToString();
                }
                if (drdChuyenThanh.SelectedIndex == 2)
                {
                    txtChuyenThanh.Text = (Convert.ToDouble(txtSoTien.Text) / Yen).ToString();
                }
                if (drdChuyenThanh.SelectedIndex == 3)
                {
                    txtChuyenThanh.Text = (Convert.ToDouble(txtSoTien.Text) / Euro).ToString();
                }
                if (drdChuyenThanh.SelectedIndex == 4)
                {
                    txtChuyenThanh.Text = (Convert.ToDouble(txtSoTien.Text) / Aus).ToString();
                }
            }
            //
            //double V = 228;
            double VND = 20900;
            double JP = 91.18;
            double EU = 0.75;
            double AS = 0.95;
            if (drdLoaiTien.SelectedIndex == 1)
            {
                if (drdChuyenThanh.SelectedIndex == 0)
                {
                    txtChuyenThanh.Text = (Convert.ToDouble(txtSoTien.Text) * VND).ToString();
                }
                if (drdChuyenThanh.SelectedIndex == 2)
                {
                    txtChuyenThanh.Text = (Convert.ToDouble(txtSoTien.Text) * JP).ToString();
                }
                if (drdChuyenThanh.SelectedIndex == 3)
                {
                    txtChuyenThanh.Text = (Convert.ToDouble(txtSoTien.Text) * EU).ToString();
                }
                if (drdChuyenThanh.SelectedIndex == 4)
                {
                    txtChuyenThanh.Text = (Convert.ToDouble(txtSoTien.Text) * AS).ToString();
                }
            }
            if (drdLoaiTien.SelectedIndex == 2)
            {
                if (drdChuyenThanh.SelectedIndex == 0)
                {
                    txtChuyenThanh.Text = (Convert.ToDouble(txtSoTien.Text) * 0.004).ToString();
                }
                if (drdChuyenThanh.SelectedIndex == 1)
                {
                    txtChuyenThanh.Text = (Convert.ToDouble(txtSoTien.Text) *0.011).ToString();
                }
                if (drdChuyenThanh.SelectedIndex == 3)
                {
                    txtChuyenThanh.Text = (Convert.ToDouble(txtSoTien.Text) *0.008).ToString();
                }
                if (drdChuyenThanh.SelectedIndex == 4)
                {
                    txtChuyenThanh.Text = (Convert.ToDouble(txtSoTien.Text) *0.01).ToString();
                }
            }
            if (drdLoaiTien.SelectedIndex == 3)
            {
                if (drdChuyenThanh.SelectedIndex == 0)
                {
                    txtChuyenThanh.Text = (Convert.ToDouble(txtSoTien.Text) *28000).ToString();
                }
                if (drdChuyenThanh.SelectedIndex == 1)
                {
                    txtChuyenThanh.Text = (Convert.ToDouble(txtSoTien.Text) *1.342).ToString();
                }
                if (drdChuyenThanh.SelectedIndex == 2)
                {
                    txtChuyenThanh.Text = (Convert.ToDouble(txtSoTien.Text) *122.34).ToString();
                }
                if (drdChuyenThanh.SelectedIndex == 4)
                {
                    txtChuyenThanh.Text = (Convert.ToDouble(txtSoTien.Text) *1.283).ToString();
                }
            }
            if (drdLoaiTien.SelectedIndex == 4)
            {
                if (drdChuyenThanh.SelectedIndex == 0)
                {
                    txtChuyenThanh.Text = (Convert.ToDouble(txtSoTien.Text) *21700).ToString();
                }
                if (drdChuyenThanh.SelectedIndex == 1)
                {
                    txtChuyenThanh.Text = (Convert.ToDouble(txtSoTien.Text) *1.046).ToString();
                }
                if (drdChuyenThanh.SelectedIndex == 2)
                {
                    txtChuyenThanh.Text = (Convert.ToDouble(txtSoTien.Text) *95.34).ToString();
                }
                if (drdChuyenThanh.SelectedIndex == 3)
                {
                    txtChuyenThanh.Text = (Convert.ToDouble(txtSoTien.Text) *0.779).ToString();
                }
            }
        }
    }
}